package de.graph.document;

import java.util.Collection;
import java.util.Set;

public interface Document {

    /**
     * The global unique id of the document.
     */
    public Long getId();

    /**
     * Return the object value associated with the provided string key.
     * 
     * @param key
     *            the key of the key/value property
     * @return the object value related to the string key
     */
    public <ValueType> ValueType getProperty(String key);

    /**
     * Return the object value associated with the provided string key or the
     * given default value if not found.
     * 
     * @param key
     *            the key of the key/value property
     * @param defaultValue
     *            the default value
     * @return the object value related to the string key
     */
    public <ValueType> ValueType getProperty(String name, ValueType defaultValue);

    /**
     * Assign a key/value property to the document. If a value already exists
     * for this key, then the previous key/value is overwritten.
     * 
     * @param key
     *            the string key of the property
     * @param value
     *            the object value o the property
     */
    public <ValueType> void setProperty(String key, ValueType value);

    /**
     * Unassigns a key/value property from the document. The object value of the
     * removed property is returned.
     * 
     * @param key
     *            the key of the property to remove from the document
     * @return the object value associated with that key prior to removal
     */
    public <ValueType> ValueType removeProperty(String key);

    /**
     * Return all the keys associated with the document.
     * 
     * @return a set of all string keys associated with the document
     */
    public Set<String> getPropertyKeys();

    /**
     * Return all the values associated with the document.
     * 
     * @return a collection of all values associated with the document
     */
    public Collection<Object> getPropertyValues();

    /**
     * Return all values for a given type associated with the document.
     * 
     * @return a collection of all values for a given type associated with the document
     */
    public <ValueType> Collection<ValueType> getPropertyValues(Class<ValueType> typeClass);

    /**
     * Remove all properties of this document.
     */
    public void clear();
}
